// pages/ucenter/message.js
var util = require('../../../utils/util.js');
var api = require('../../../config/api.js');



var app = getApp();

Page({
  data: {
    array: ['请选择反馈类型', '商品相关', '物流状况', '客户服务', '优惠活动', '功能异常', '产品建议', '其他'],
    index: 0,
    message: {
      user_mobile:'',
      msg_content: ''
    },
  },
  bindPickerChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      index: e.detail.value
    })
  },
  onLoad: function (options) {
  },
  onReady: function () {

  },
  onShow: function () {

  },
  bindinputMobile(event) {
    let message = this.data.message;
    message.user_mobile = event.detail.value;
    this.setData({
      message: message
    });
  },
  bindinputcontent(event) {
    let message = this.data.message;
    message.msg_content = event.detail.value;
    this.setData({
      message: message
    });
  },
  sumbitmessage:function()
  {
    console.log(this.data.message)
    let message = this.data.message;
    if (message.user_mobile == '') {
      util.showErrorToast('请输入手机号');
      return false;
    }
    if (message.msg_content == '') {
      util.showErrorToast('请输入留言内容');
      return false;
    }

    let that = this;
    util.request(api.FeedBackSave, {
      user_mobile: message.user_mobile,
      msg_content: message.msg_content
    }, 'POST').then(function (res) {
      if (res.errno === 0) {
        console.log("保存成功");
        wx.showToast({
          title: "保存成功",
          mask: true
        });
        util.redirectTo("../../pages/kefu/kefu");
      }
    });
  },
  onHide: function () {
    // 页面隐藏

  },
  onUnload: function () {
    // 页面关闭
  }
})